import { createRouter, RouteRecordRaw, createWebHashHistory } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/login',
        meta: {
            notNeedCheckToken: true
        },
        component: () => import('../components/Login.vue')
    },
    {
        path: '/home',
        component: () => import('@/components/Home.vue'),
        redirect: '/home/gamelist',
        children: [
            {
                path: 'user', // 这样写会自动拼接上父级的路径
                component: () => import('@/components/UserCenter.vue'),
                redirect: 'user/setting',
                children: [{
                    path: 'setting',
                    component: () => import('@/components/userMenu/ChangeUser.vue'),
                }, {
                    path: 'avatar',
                    component: () => import('@/components/userMenu/MyAvatar.vue'),
                }, {
                    path: 'security',
                    component: () => import('@/components/userMenu/UserSecurity.vue'),
                }]
            },
            {
                path: 'gamelist',
                component: () => import('@/components/GameList.vue')
            },
            {
                path: 'changeImpMsg',
                component: () => import('@/components/userMenu/ChangeStep.vue')
            },
            {
                path: 'game',
                component: () => import('@/components/games/Game.vue')
            }
        ]
    },

]
const router = createRouter({
    history: createWebHashHistory(),
    routes
})

export default router